package com.qining618.cms.cms.mapper;

import com.qining618.cms.cms.domain.ContentRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qining618.cms.cms.enums.ContentOperateEnum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * 内容操作记录 Mapper 接口
 * </p>
 *
 * @author qining
 * @date 2019-09-20
 */
@Mapper
@Repository
public interface ContentRecordMapper extends BaseMapper<ContentRecord> {

    /**
     * 用户内容操作记录是否存在
     * @param contentId 内容id
     * @param userId 用户id
     * @param operateType 操作类型
     * @return boolean 是否存在
     */
    @Select("select count(1) from c_content_record where content_id = #{contentId} and user_id = #{userId} and operate_type = #{operateType}")
    boolean existByContentIdAndUserIdAndOperateType(
            @Param("contentId") Long contentId,
            @Param("userId") Long userId,
            @Param("operateType") ContentOperateEnum operateType);
}
